package hihocode;

import java.util.HashMap;
import java.util.Scanner;

//并查集
public class UnionFind {

	public static void main(String[] args) {
		Scanner scanner = new Scanner(System.in);
		HashMap<String, Integer> map = new HashMap<>();
		int n = scanner.nextInt();
		int operate;
		String name1, name2;
		//维护着名字到下标的映射
		int index = 0;
//		UF uf = new UF(2 * n);
		for(int i = 0; i < n; i++){
			operate = scanner.nextInt();
			name1 = scanner.next();
			name2 = scanner.next();
			scanner.nextLine();
			int nameIndex1, nameIndex2;
			if(map.containsKey(name1)){
				nameIndex1 = map.get(name1);
			}else{
				map.put(name1, index);
				nameIndex1 = index++;
			}
			if(map.containsKey(name2)){
				nameIndex2 = map.get(name2);
			}else{
				map.put(name2, index);
				nameIndex2 = index++;
			}
//			System.out.println("nameIndex1: " + nameIndex1 + " nameIndex2: " + nameIndex2);
			if(operate == 0){
				int nUserId1 = findRepresent(nameIndex1);
				int nUserId2 = findRepresent(nameIndex2);
				if (nUserId1 != nUserId2){
					unionSet(nUserId1, nUserId2);
				}
				//uf.union(nameIndex1, nameIndex2);
			}else{
				int nUserId1 = findRepresent(nameIndex1);
				int nUserId2 = findRepresent(nameIndex2);
				if (nUserId1 != nUserId2){
					System.out.println("no");
				}else{
					System.out.println("yes");
				}
//				if(uf.isUnion(nameIndex1, nameIndex2)){
//					System.out.println("yes");
//				}else{
//					System.out.println("no");
//				}
			}
//			System.out.println(uf.id[nameIndex1] + " " + uf.id[nameIndex2]);
		}
		scanner.close();
	}
	
	private static class UF{
		int[] id;
		int count;
		public UF(int n){
			id = new int[n];
			count = n;
			for(int i = 0; i < n; i++){
				id[i] = i;
			}
		}

		public void union(int i, int j) {
			int temp = id[i];
			if (id[i] == id[j]) {
				return;
			}
			// 然后将所有的i所属的组全部变为j所属组的值
			for (int k = 0; k < id.length; k++) {
				//注意这里不要写id[k] == id[i]因为如果i等于0，那么id[i]的值要改变
				//应该先用一个值将该值存储起来
				if (id[k] == temp) {
					id[k] = id[j];
				}
			}
			// 组的个数减一
			count--;
		}
		public boolean isUnion(int i, int j){
			return id[i] == id[j];
		}
	}
	
	//每个集合的代表元素
	static int[] arrRepresent = new int[10001];
	
	static int findRepresent(int x){
		if (arrRepresent[x] != x)
			arrRepresent[x] = findRepresent(arrRepresent[x]);
		return arrRepresent[x];
	}

	static void unionSet(int x, int y) {
		arrRepresent[x] = y;
	}
}
